package com.yand.thinkingInJava.thinkingInJava21.daemon;


import java.util.concurrent.TimeUnit;

/**
 * 简单后台线程测试
 */
public class SimpleDaemons implements Runnable {





    @Override
    public void run() {
        try {
            while(true){
               TimeUnit.MILLISECONDS.sleep(100);
               System.out.println(Thread.currentThread()+" "+this);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



    public static void main(String [] args){

        System.out.println("All deamon start");
         for(int i = 0 ; i< 10; i ++){
              Thread daemon = new Thread(new SimpleDaemons());
              daemon.setDaemon(true);
              daemon.start();
         }

     /*  try {
            TimeUnit.MILLISECONDS.sleep(170);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
    }
}
